%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Algorithm function %%%%%%%%%%%%%%%%%%%%%%%%
% 1 local maximum point 
% [0.0000 1.6000 12.28530]（global maximum point ） 
% [-1.800 0.9500 7.107760]
% [1.2000 0.0000 11.99900]
% [-0.250 0.6000 11.14050]
% 2 local minimum point
% [-1.200 -0.100 -11.1405]（global minimum point ）
% [0.1500 -1.700 -9.36985]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function z=target(X,Y,varargin)
if(nargin==1)
    if(size(X,1)==2)
        x=X(1,:);
        y=X(2,:);
    elseif(size(X,2)==2)
        x=X(:,1);
        y=X(:,2); 
    else
        error('Input Data Error!')
    end
    z =  (1-x).^2.*exp(-(x.^2) - (y+1).^2) ... 
       - 15*(x/5 - 2*x.^3 - y.^5).*exp(-x.^2-y.^2) ... 
       - exp(-(x+1).^2 - y.^2)...
       + 15*(1-y+x).^2.*exp(-(x+1).^2-y.^2);
%     z=-z;
elseif(nargin==2)
    x=X;
    y=Y;
    z =  (1-x).^2.*exp(-(x.^2) - (y+1).^2) ... 
       - 15*(x/5 - 2*x.^3 - y.^5).*exp(-x.^2-y.^2) ... 
       - exp(-(x+1).^2 - y.^2)...
       + 15*(1-y+x).^2.*exp(-(x+1).^2-y.^2);
%     z=-z;
end

end